#include <stdio.h>
#include <stdlib.h>
#include "label.h"
#include "register.h"
#include "AAT.h"
#include "AATPrintTree.h"
#include "AATBuildTree.h"
#include <string.h>

#include "codegen.h"
#include "tests.h"

extern FILE *yyin;


int main(int argc, char **argv) {
  FILE *output;
  char *outfilename;
  
  AATstatement stat;

  if (argc!=2) {
    fprintf(stderr,"usage: %s filename\n",argv[0]); 
    return 1;
  }

  outfilename = (char *) malloc((strlen(argv[1]) + 3) * sizeof(char));
  strcpy(outfilename,argv[1]);
  strcat(outfilename,".s");

  // PUT HERE TEST NAME WHICH YOU WANT TO INVESTIGATE (tests.h)
  stat = quickSort();
  
  printf("Abstract Assembly Tree\n");
  printf("--------------------\n");

  printAAT(stat);
  output = fopen(outfilename, "w");
  generateCode(stat, output);
 
 return 0;
}

